package com.jwdemo
{
	// Simple Enemy Manager 
	// TODO Need to add in concept of 'region' to partition rendering and updating
	// TODO use GameObject Manager for main update and rendering loops?
	
	public class EnemyManager
	{
		private static var eMan:EnemyManager  ;
		
		private var enemies:Vector.<Enemy> ;
		
		function EnemyManager()
		{
			enemies = new Vector.<Enemy> () ;
			
		}
		
		
		public static function Init(enemyData:Array = null, regionHelper:InfRegionHelper = null, rHelper:RenderHelper = null) : void
		{
			
			eMan	=	new EnemyManager() ;
			if (enemyData)
			{
				for(var idx:uint = 0 ; idx < enemyData.length ; idx++)
				{
					var property:Object = enemyData[idx] ;
					//EnemyManager.Add(Enemy.Create(property)) ;
					
				}
			}
			
		}
		
		public static function Add(enemy:Enemy) : void
		{
			eMan.enemies.push(enemy) ;
		}

		
		
		public static function Remove(enemy:Enemy) : void
		{
			//TODO
			//eMan.enemies.delete(enemy.getIndex()) ;
		}

		public static function getEnemy(index:uint) : Enemy 
		{
			return eMan.enemies[index] ;
		}

		public static function Update(dt:Number) : void
		{
			for each (var enemy:Enemy in eMan.enemies) {
				enemy.update(dt) ;
			}
							
		}

		public static function Render(rHelper:RenderHelper) : void
		{
			for each (var enemy:Enemy in eMan.enemies) {
				enemy.render(rHelper) ;
			}
		}
	
	}
}